PR: Add some macros related to working with bytes and bits#536
Open
DRSDavidSoft wants to merge 1 commit intoarduino:masterfrom
Open
PR: Add some macros related to working with bytes and bits#536DRSDavidSoft wants to merge 1 commit intoarduino:masterfrom
DRSDavidSoft wants to merge 1 commit intoarduino:masterfrom
Conversation
|
|
|
Memory usage change @ f9a3c08
Click for full report table
Click for full report CSV |
|
Nice |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds some useful macros for manipulating bytes and bits in C/C++. The existing code already had some macros for low and high bytes, bit reading, setting, clearing, toggling and writing. I added the following macros:
packToInt(h,l): This macro takes two bytes (high and low) and packs them into a 16-bit integer.packToLong(i3,i2,i1,i0): This macro takes four bytes and packs them into a 32-bit long integer.bitIsSet(value, bit): This macro returns true if the given bit in the value is set (1).bitIsClear(value, bit): This macro returns true if the given bit in the value is clear (0).These macros can be useful for working with binary data, such as serial communication, encryption, compression, etc. They can also make the code more readable and concise.
I hope you find this PR useful and I welcome any feedback or suggestions.
Note: This excerpt was generated by ChatGPT. The code is written by me.